package com.hoshiicloud.suppplier.feign;

import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.suppplier.feign.hystrix.HystrixVeriCenterFeignFallback;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotBlank;

/**
 * @author yangcheng
 * @version 1.0
 * @title: veriCenterFeignService
 * @description: 验证中心微服务FeignClient
 * @date 2019/5/30 17:59
 * @mail maiboyc@163.com
 */
@FeignClient(name = "hoshiicloud-vericenter", fallback = HystrixVeriCenterFeignFallback.class)
@Repository
public interface VeriCenterFeignService {

    /**
     * 发送短信验证码
     *
     * @param mobile    手机号码
     * @param code      验证码
     * @param expSecond 有效时间(单位:秒)
     * @return Response<SmsMsgResponse>
     */
    @RequestMapping(value = "/sms/sendCode", method = RequestMethod.POST)
    Response sendCode(@RequestParam("mobile") String mobile, @RequestParam("code") String code, @RequestParam("expSecond") long expSecond);

    /**
     * 校验验证码
     *
     * @param msgId 短信ID
     * @param code  验证码
     * @return Response
     */
    @RequestMapping(value = "/sms/check", method = RequestMethod.POST)
    Response checkCode(@RequestParam("msgId") String msgId, @RequestParam("code") String code);

    /**
     * 使用模板发送短信
     *
     * @param mobile   手机号码
     * @param tplValue 模板参数，json字符串格式
     * @param tplId    模板ID
     * @return Response
     */
    @RequestMapping(value = "/sms/sendTplMsg", method = RequestMethod.POST)
    Response sendTplMsg(@RequestParam("mobile") String mobile, @RequestParam("tplValue") String tplValue, @RequestParam("tplId") String tplId);

    /**
     * 使用短信模板批量发送短信
     *
     * @param mobile   手机号码，多个手机号码以逗号隔开
     * @param tplValue 模板参数，json字符串格式
     * @param tplId    模板ID
     * @return Response
     */
    @RequestMapping(value = "/sms/batchSendTplMsg", method = RequestMethod.POST)
    Response batchSendTplMsg(@RequestParam("mobile") String mobile, @RequestParam("tplValue") String tplValue, @RequestParam("tplId") String tplId);


    @RequestMapping(value = "/user/idCardOcr",method = RequestMethod.POST)
    @ApiOperation(value = "身份证ocr识别接口",notes = "data正常返回内容见接口文档:https://market.aliyun.com/products/57124001/cmapi010401.html")
    @ApiImplicitParams({ @ApiImplicitParam(name = "image", value = "图片url或图片base64字符串", dataType = "String", required = true,example = ""),
            @ApiImplicitParam(name = "side", value = "身份证正反面 face或back", dataType = "String", required = true,example = "face") })
    Response idCardOcrDiscern(@RequestParam("image") @NotBlank String image, @RequestParam("side") @NotBlank String side);
}
